package org.jeecg.modules.util;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyuncs.exceptions.ClientException;

import java.io.File;

public class Demo {
    public static void main(String[] args) throws ClientException {
        // OSS访问域名。以华东1（杭州）地域为例，填写为https://oss-cn-hangzhou.aliyuncs.com。其它Region请按实际情况填写。
        String endpoint = "oss-rg-china-mainland.aliyuncs.com";
        // 从环境变量中获取步骤1.5生成的临时访问密钥AccessKey ID和AccessKey Secret，非阿里云账号AccessKey ID和AccessKey Secret。
        String accessKeyId ="STS.NWzCPtXRsVJAFSZ5SBTY8a1xM";
        String accessKeySecret = "AbrvXiPjay85nsGaAuFGxXwpc2s8LfSjot4qeSS9yHzu";
        // 从环境变量中获取步骤1.5生成的安全令牌SecurityToken。
        String securityToken = "CAISwQJ1q6Ft5B2yfSjIr5TPCOrAtY1S4YiqRHXr0VMXWNYUjvTTrzz2IHhMf3FqCekcsf8wlWpW6vYZlqd5SpBrREjJVsZr9ZVQ91t22QdlCZbng4YfgbiJREKxaXeiruKwDsz9SNTCAITPD3nPii50x5bjaDymRCbLGJaViJlhHL91N0vCGlggPtpNIRZ4o8I3LGbYMe3XUiTnmW3NFkFlyGEe4CFdkf3imZPFu0qA1w2lk7FF+djLT8L6P5U2DvBWSMyo2eF6TK3F3RNL5gJCnKUM1/Qcom+d7ojHXAIOsk/Yb7qP6LJ1Kwt0b7I8CwajbWE1WEgSUIXx4GeXo34lVYk9O69v0107XI6PUWUlYmPd2WJn+ZBZ6JHuUNe8+khPOgkwX2AxMJFCERRbamdXIVy0Z9HhlhmkDQnLVlWkUf9eufIagAEYwQZ+dU9eTrl+pLPmGmHrs4qeMgfBVrJuHIVN7YQUbT9LJL88Z2vkNKYccDFuc/DCutbNzkTb1k0uNM5AWPF7Nl5l/HVs1I7yuai4wzSvrZvV2PQ/wNHlFmXuqzwIu1refuCebtg3XfbI0q6eEeK7rT9xxzHIGSkLhV6VB7oZhSAA";

        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret, securityToken);
        // 将本地文件exampletest.txt上传至examplebucket。
        PutObjectRequest putObjectRequest = new PutObjectRequest("nike-huolixiaoyuan", "exampletest.txt", new File("D:\\exampletest.txt"));

        // ObjectMetadata metadata = new ObjectMetadata();
        // 上传文件时设置存储类型。
        // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());
        // 上传文件时设置读写权限ACL。
        // metadata.setObjectAcl(CannedAccessControlList.Private);
        // putObjectRequest.setMetadata(metadata);
/*
        try {
            // 上传文件。
            ossClient.putObject(putObjectRequest);
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }*/

        String str = "jAzbtXX8eOx3BAdU4c7nh36d69WBBzWLOAJBR+w1Xy3ZEGI8y3Cb64SepYLQ0eVv";
        System.out.println(str.length());
    }
}